<%-- 
    Document   : index
    Created on : Apr 21, 2012, 7:01:58 PM
    Author     : TANGQUOCTUAN
--%>

<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<link href="JQuery/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="JQuery/jquery.min.js"></script>
<script src="JQuery/jquery-ui.min.js"></script>
<script src="JQuery/jquery-ui-timepicker-addon.css"></script>
<script src="JQuery/jquery-ui-timepicker-addon.js"></script>

<%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <script>
            $(function() {
                $( "#datepicker" ).datetimepicker();
                $( "#datepickers" ).datetimepicker();
            });
        </script>
        <script>
            function addDate(){
                date = new Date();
                var month = date.getMonth()+1;
                var day = date.getDate();
                var year = date.getFullYear();

                var currentTime = new Date()
                var hours = currentTime.getHours()
                var minutes = currentTime.getMinutes()
                if (minutes < 10)
                    minutes = "0" + minutes

                if (document.getElementById('current').value == ''){
                    document.getElementById('current').value = ((''+month).length<2 ? '0' : '') + month +  '/' + ((''+day).length<2 ? '0' : '') + day + '/' + year + " " + hours + ":" + minutes;
                }
            }
        </script>
        <script type="text/javascript">
            function check(){
                var capacity = document.getElementById("capacity");
                var start = document.getElementById("datepicker");
                var end = document.getElementById("datepickers");
                var resphone=/^[\d]{1,}$/;
                var current = document.getElementById("current");

                if(capacity.value.length==0){
                    alert("This field is required");
                    f.txtcap.focus();
                    return false;
                }

                if(resphone.test(capacity.value)==false){
                    alert("Capacity must be numberic");
                    f.txtcap.focus();
                    return false;
                }

                if(capacity.value==0){
                    alert("Capacity must be bigger than 0");
                    f.txtcap.focus();
                    return false;
                }

                if(start.value.length==0){
                    alert("Choose Start day");
                    return false;
                }

                if(start.value<=current.value){
                    alert("Choose wrong or time in start day");
                    return false;
                }                

                if(end.value.length==0){
                    alert("Choose End day");
                    return false;
                }

                if(end.value<=current.value){
                    alert("Choose wrong or time in end day");
                    return false;
                }

                if(start.value > end.value){
                    alert("End day must be bigger than start day");
                    return false;
                }
                return true;
            }
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tunga Restaurant</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body onload="addDate();">
        <center>
            <c:set var="session" value="${sessionScope.user}"/>
            <c:if test="${empty session}">
                <script>
                    function h()
                    {
                        window.location="index.jsp"
                    }
                </script>
            </c:if>
            <div class="outer">
                <!--Header end-->
                <div id="rc1"></div>
                <div id="bg">
                    <div class="toplinks"><a href="ContactUs.jsp">Contact us</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="initShowFood?action=Food">Food</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerTables?action=Table">Table</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerRooms?action=Room">Room</a></div><div class="sap">|</div>
                    <c:if test="${empty session}">
                        <div class="toplinks"><a href="registration.jsp">Register</a></div><div class="sap">|</div>
                        <div class="toplinks"><a href="login.jsp">Login</a></div><div class="sap">|</div>
                    </c:if>
                    <div class="toplinks"><a href="index.jsp">Home Page</a></div>
                    <div><font color="white">Welcome, </font><font color="yellow">${sessionScope.user}</font> </div>
                    <div>
                        <font color="yellow"><a href="ControllerCustomer?action=Information&user=${sessionScope.user}">Your information</a></font>
                        <%
                                    if (session.getAttribute("isadmin") != null) {
                        %>
                        <a href="index_admin.jsp">Admin Manager</a>
                        <%                                    }
                        %>
                        <font color="yellow">
                            <c:url var="LogOut" value="ControllerCustomer">
                                <c:param name="action" value="LogOut"/>
                            </c:url>
                            <a href="${LogOut}">LogOut</a>
                        </font>
                    </div>
                </div>
                <div id="rc2"></div>
                <div id="header">
                    <div class="name">Tunga Restaurant</div>
                    <div class="tag">The best restaurant in the world</div>
                </div>
                <!--Top nav end-->
                <div style="clear:left"></div>
                <div id="outer2">
                    <div id="left-nav">
                        <div class="leftlinks">
                            <span class="heading">Quick Links</span>
                            <ul>
                                <li><a href="index.jsp">Home Page </a></li>
                                <li><a href="ControllerRooms?action=Room">Room</a></li>
                                <li><a href="ControllerTables?action=Table">Table</a></li>
                                <li><a href="initShowFood?action=Food">Food</a></li>
                                <c:if test="${not empty session}">
                                    <li><a href="ControllerRooms?action=BookRoom">Book Room</a></li>
                                    <li><a href="ControllerTables?action=BookTable">Book Table </a></li>
                                    <li><a href="addToCart.jsp">Shopping Cart</a></li>
                                </c:if>
                                <li><a href="ContactUs.jsp">Contact Us </a></li>
                            </ul>
                        </div>
                    </div><div class="inner_copy"><div class="inner_copy">All <a href="http://www.magentothemesworld.com" title="Best Magento Templates">premium Magento themes</a> at Magentothemesworld.com!</div></div>
                    <div id="content">
                        <span class="heading">Book Room</span>
                        <div id="main">
                            <form action="ControllerRooms" id="testform" name="f" onsubmit="return check();">
                                <c:set var="load" value="${applicationScope.name}"/>
                                <c:set var="loadres" value="${applicationScope.resid}"/>
                                <table border="0" align="center">
                                    <tbody>                                       
                                        <tr>
                                            <td>Room :</td>
                                            <td><select name="txtroom">
                                                    <c:forEach var="al" items="${load}">
                                                        <option value="${al.roomID}">${al.roomName}</option>
                                                    </c:forEach>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Restaurant Name:</td>
                                            <td><select name="txtid">
                                                    <c:forEach var="rs" items="${loadres}">
                                                        <option value="${rs.resID}">${rs.resName}</option>
                                                    </c:forEach>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Customer ID:</td>
                                            <td><input type="text" name="txtcustid" value="${sessionScope.user}" readonly /></td>
                                        </tr>
                                        <tr>
                                            <td>Capacity :</td>
                                            <td><input type="text" name="txtcap" id="capacity"/></td>
                                        </tr>
                                        <tr>
                                            <td>Start Day :</td>
                                            <td><input id="datepicker" type="text" name="txtstart" readonly/></td>
                                        </tr>
                                        <tr>
                                            <td>End Day :</td>
                                            <td><input id="datepickers" type="text" name="txtend" readonly/></td>
                                        </tr>
                                        <tr>
                                            <td>Reserve Fee :</td>
                                            <td><input type="text" name="txtreserve" value="150" readonly="true" /></td>
                                        </tr>                                    
                                        <tr>
                                            <td></td>
                                            <td><input type="submit" value="Book" name="action" /> <input type="reset" value="Reset" /></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                            <input type="hidden" id="current" readonly="true"/>
                        </div>
                    </div>
                    <div style="clear:left"></div>
                </div>
                <!--Bottom part-->
                <div id="bottom">
                    <div id="footer"><div class="fcenter">GROUP02-F5-10-1009-S1</div></div>
                </div>
            </div>
        </center>
    </body>
</html>
